<template>
  <page-view class="box">
    <mheader>
        <div class="iconfont icon-return back" @click="$router.back()" slot="back"></div>
      <div slot="body">城市列表</div>
    </mheader>
    <div class="content">
      <div class="header">
        当前定位城市为:
        <span style="color:orange;font-weight:bold">武汉</span>
      </div>
      <div class="cityList" v-for="(item,index) in cityList" :key="index">
        <div class="title">{{index}}</div>
        <div class="cityItem" v-for="(item1,index1) in item" :key="index1">{{item1.nm}}</div>
      </div>
      <div class="firstLetter" >
        <span  v-for="(item,index) in cityList" :key="index">{{index}}</span>
      </div>
    </div>
  </page-view>
</template>
<script>
import Mheader from "../components/MHeader.vue";
import dataFormat from "../utils/dataFormat";
export default {
  name: "City",
  data() {
    return {
      cityList: []
    };
  },
  async created() {
    if (!localStorage.getItem("cityList")) {
      let resp = await this.$http.get("/maoyanApi/dianying/cities.json");
      localStorage.setItem("cityList", JSON.stringify(resp.data.cts));
    }
    this.cityList = dataFormat(JSON.parse(localStorage.getItem("cityList")));
  },
  components: {
    Mheader
  }
};
</script>
<style lang="scss" scoped>
.box{
  display: flex;
  flex-direction: column;
}
.back {
  position: absolute;
  left: 0.2rem;
  font-size: 0.6rem;
}
.content {
  flex:1;
  overflow: auto;
  box-sizing: border-box;
  padding: 0 0.2rem;
  background: #f5f5f5;
  .header {
    padding: 0.1rem;
    box-sizing: border-box;
    border-bottom: 1px solid gray;
  }
  .title {
    color: var(--pColor);
    font-weight: bold;
    font-size: 0.36rem;
  }
  .cityItem {
    box-sizing: border-box;
    padding: 0.1rem 0;
    border-bottom: 1px solid gray;
  }
  .firstLetter {
    position: fixed;
    top: 1.2rem;
    bottom: 0.6rem;
    right: 0.3rem;
    width: 0.6rem;
    z-index: 9999;
    border-radius: 0.3rem;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    font-size: .4rem;
  }
}
</style>